package com.swdegao.iot.netty.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.swdegao.iot.netty.mqtt.MqttPushClient;
import com.swdegao.iot.netty.service.MqttCommandService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class MqttCommandImpl implements MqttCommandService{
    @Autowired
    private MqttPushClient mqttPushClient;// mqtt推送端

    @Override
    public JSONObject mqttPublish(int qos, boolean retained, String topic, String pushMessage){
        log.info("主题" + topic + "，消息发布内容：" + pushMessage);
        String res = mqttPushClient.publish(qos, retained, topic, pushMessage);// 执行消息发布

        JSONObject jo = new JSONObject();
        jo.put("msg",res);
        return jo;
    }
}
